﻿using System;
using System.Threading;
//using System.Windows.Forms;
using System.IO;
using System.Windows;

namespace client.app
{
    static class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            Thread.CurrentThread.IsBackground = true;

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler((o, e) =>
            {
                File.AppendAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log.txt"),
                    "=========== " + DateTime.Now + " :\r\n" + e.ExceptionObject.ToString() + "\r\n");

                MessageBox.Show(e.ExceptionObject.ToString());
            });

            var app = new Application();
            var mainWindow = new gui2.MainWindow(app);

            comm.ThreadHelper.Run(() =>
            {
                using (var gameManager = new MainGame(mainWindow))
                {
                    gameManager.Run();
                }
            });

            app.Run(mainWindow);
        }
    }
}
